<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/4/13
  Time: 17:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="css/pintuer.css">
    <link rel="stylesheet" href="css/admin.css">
    <script src="js/jquery.js"></script>
    <script src="js/pintuer.js"></script>
</head>
<body>

<form method="post" action="">
    <div class="panel admin-panel">
        <div class="panel-head"><strong class="icon-reorder">部门管理</strong></div>

        <div class="padding border-bottom">
            <ul class="search">
                <li>
                    <button type="button" class="button border-green" id="checkall"><span class="icon-check"></span> 全选
                    </button>
                    <button type="submit" class="button border-red"><span class="icon-trash-o"></span> 批量删除</button>
                </li>
            </ul>
        </div>
        <table class="table table-hover text-center">
            <tr>
                <th width="120">部门ID</th>
                <th>部门名称</th>
                <th>部门地址</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${detpList.dataList}" var="detpList">
                <tr>
                    <td> ${detpList.detpId}</td>
                    <td> ${detpList.detpName}</td>
                    <td> ${detpList.detpAddress}</td>
                    <td>
                        <div class="button-group"><a class="button border-blue" href="javascript:void(0)"
                                                     onclick="return updateDept(${detpList.detpId})"><span class="icon-trash-o"></span> 修改</a>
                        </div>
                        <div class="button-group"><a class="button border-red" href="javascript:void(0)"
                                                     onclick="return del(${detpList.detpId})"><span class="icon-trash-o"></span> 删除</a>
                        </div>
                    </td>
                </tr>
            </c:forEach>

            <tr>
                <td colspan="8">
                    <div class="pagelist">
                        共${detpList.totalPageNumber}页
                        <a href="${pageContext.request.contextPath}/deptPage.do?currentNum=1">首页</a>
                        <a href="${pageContext.request.contextPath}/deptPage.do?currentNum=${detpList.prePageNumber}">上一页</a>
                        <c:forEach var="bianhaoelement" begin="1" end="${detpList.totalPageNumber}" step="1">
                        <a href="${pageContext.request.contextPath}/deptPage.do?currentNum=${bianhaoelement}">${bianhaoelement}</a>
                        </c:forEach>
                        <a href="${pageContext.request.contextPath}/deptPage.do?currentNum=${detpList.nextPageNumber}">下一页</a>
                        <a href="${pageContext.request.contextPath}/deptPage.do?currentNum=${detpList.totalPageNumber}">尾页</a>
                </td>
            </tr>
        </table>
    </div>
</form>
<script type="text/javascript">

    function updateDept(id) {
        if (confirm("您确定要修改"+id+"吗?")) {
            console.log(id);
            window.location.href="${pageContext.request.contextPath}/updateDeptPage.do?id="+id;
        }
    }
    function del(id) {
        if (confirm("您确定要删除吗?")) {
            window.location.href="${pageContext.request.contextPath}/deleteDept.do?id="+id;
        }
    }

    $("#checkall").click(function () {
        $("input[name='id[]']").each(function () {
            if (this.checked) {
                this.checked = false;
            } else {
                this.checked = true;
            }
        });
    })

    function DelSelect() {
        var Checkbox = false;
        $("input[name='id[]']").each(function () {
            if (this.checked == true) {
                Checkbox = true;
            }
        });
        if (Checkbox) {
            var t = confirm("您确认要删除选中的内容吗？");
            if (t == false) return false;
        } else {
            alert("请选择您要删除的内容!");
            return false;
        }
    }

</script>
</body>
</html>